package com.shelpe.services.sinbad.controller;

import lombok.Data;
import lombok.Getter;

@Data
public class SearchCriteria {
	private String key;
    private String operation = Operation.eq.name();
    private String value;
    
    public SearchCriteria(){
    	
    }
    
    public SearchCriteria(String k, String v){
    	this.key = k;
    	this.value = v;
    }
    
    
    public Operation operation(){
    	return Operation.from(this.operation);
    }
    
    @Getter
    public static enum Operation{
    	gt(">"),gte(">="),eq("="),lt("<"),lte("<="),like(":");
    	
    	private String symbol;
    	
    	private Operation(String s){
    		this.symbol = s;
    	}
    	
        public static Operation from(String value) {
    		Operation op = Operation.eq;
    		for(Operation v:Operation.values()){
    			if(v.name().equals(value)){
    				op = v;
    			}
    		}
    		return op;
        }

    }
}
